
// cef版本 调用客户端方法
export function invokeAPi () {
  var a = Array.prototype.slice.call(arguments)
  if (['dll', 'repairmaster'].includes(process.env.VUE_APP_NAME) && a[0] === 'HtmlClickReport' && a[1].ReportID) { // dll，劫持xz上报方法，修改方法名和参数
    const reportID = a[1].ReportID
    a = ['xz_substat_action', reportID]
  }
  return window.xz_call && window.xz_call.apply(this, a)
}

export function invokeAsyncAPi () {
  var a = Array.prototype.slice.call(arguments)
  return new Promise((resolve) => {
    a.push((...args) => resolve(args.length > 1 ? args : args[0]))
    window.xz_call && window.xz_call.apply(this, a)
  })
}

export function registerInformApi (apiName, cb) {
  (window.xz_register && window.xz_register(apiName, cb)) || (window[apiName] = cb)
}
